package model;

public class Counter extends Observee {
	
	private static final int CounterInitialvalue = 0;
	
	public static Counter createCounter(){
		return new Counter(CounterInitialvalue);
	}
	
	private int currentValue;
	
	private Counter(int value){
		this.currentValue = value;
	}
	public void up(){
		this.setCurrentValue(this.getCurrentValue() + 1);
		this.notifyObservers(UpEvent.create());
	}
	public void down(){
		this.setCurrentValue(this.getCurrentValue() - 1);
		this.notifyObservers(DownEvent.create());
	}
	public int getCurrentValue() {
		return this.currentValue;
	}
	public void setCurrentValue(int value) {
		this.currentValue = value;
	}
	public void reset() {
		this.setCurrentValue(CounterInitialvalue);
		this.notifyObservers(ResetEvent.create());
	}
}
